package com.zzxx.mapper;

import com.zzxx.domain.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductMapper {

    @Select("select * from product")
    List<Product> findAll();

    @Select("select * from product where id = #{id}")
    Product findProductById(String id);

    @Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},departureTime=#{departureTime},productPrice=#{productPrice},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id = #{id}")
    void updateProductById(Product product);

    @Insert("insert into product" +
            "(id,productNum,productName,cityName,departureTime,productPrice,productDesc,productStatus) " +
            "values (#{id},#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus}) ")
    void insert(Product product);

    @Delete("delete from product where id = #{id}")
    void deleteProduct(String id);
}
